import type {
  User,
  LoginForm,
  GetCodeForm,
  UserInfo,
  BindForm
} from '@/types/user'
import http from '@/utils/http'

export function userPasswordLoginApi(data: LoginForm) {
  return http.post<User>('/login/password', data)
}

export function userCodeLoginApi(data: LoginForm) {
  return http.post<User>('/login', data)
}

export function getCodeApi(params: GetCodeForm) {
  return http.get('/code', params)
}

export function getUserInfoApi() {
  return http.get<UserInfo>('/patient/myUser')
}

export const userLoginByQQApi = (openId: string) =>
  http.post<User>('/login/thirdparty', { openId, source: 'qq' })

export const bindUserQQAndMobileApi = (data: BindForm) =>
  http.post<User>('/login/binding', data)
